package com.yeban.bams.utils;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Desc 自定义线程池（负责执行客户端请求任务）
 * @Author yeban
 * @Date 2025/11/6
 */
public class ThreadPool {

    private ThreadPoolExecutor pool;

    public ThreadPool(int corePoolSize, int maxPoolSize, int queueSize) {
        pool = new ThreadPoolExecutor(
                corePoolSize, maxPoolSize, 60, TimeUnit.SECONDS,
                new LinkedBlockingQueue<Runnable>(queueSize),
                new ThreadPoolExecutor.AbortPolicy()
        );
    }

    // 执行方法
    public void execute(Runnable runnable) {
        pool.submit(runnable);
    }
}
